{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "导入包和数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import pickle\n",
    "from sklearn.decomposition import PCA"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_csv('Otto_train.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>feat_1</th>\n",
       "      <th>feat_2</th>\n",
       "      <th>feat_3</th>\n",
       "      <th>feat_4</th>\n",
       "      <th>feat_5</th>\n",
       "      <th>feat_6</th>\n",
       "      <th>feat_7</th>\n",
       "      <th>feat_8</th>\n",
       "      <th>feat_9</th>\n",
       "      <th>...</th>\n",
       "      <th>feat_85</th>\n",
       "      <th>feat_86</th>\n",
       "      <th>feat_87</th>\n",
       "      <th>feat_88</th>\n",
       "      <th>feat_89</th>\n",
       "      <th>feat_90</th>\n",
       "      <th>feat_91</th>\n",
       "      <th>feat_92</th>\n",
       "      <th>feat_93</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>Class_1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 95 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  feat_1  feat_2  feat_3  feat_4  feat_5  feat_6  feat_7  feat_8  feat_9  \\\n",
       "0   1       1       0       0       0       0       0       0       0       0   \n",
       "1   2       0       0       0       0       0       0       0       1       0   \n",
       "2   3       0       0       0       0       0       0       0       1       0   \n",
       "3   4       1       0       0       1       6       1       5       0       0   \n",
       "4   5       0       0       0       0       0       0       0       0       0   \n",
       "\n",
       "   ...  feat_85  feat_86  feat_87  feat_88  feat_89  feat_90  feat_91  \\\n",
       "0  ...        1        0        0        0        0        0        0   \n",
       "1  ...        0        0        0        0        0        0        0   \n",
       "2  ...        0        0        0        0        0        0        0   \n",
       "3  ...        0        1        2        0        0        0        0   \n",
       "4  ...        1        0        0        0        0        1        0   \n",
       "\n",
       "   feat_92  feat_93   target  \n",
       "0        0        0  Class_1  \n",
       "1        0        0  Class_1  \n",
       "2        0        0  Class_1  \n",
       "3        0        0  Class_1  \n",
       "4        0        0  Class_1  \n",
       "\n",
       "[5 rows x 95 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "index = df['id']\n",
    "y = df['target']\n",
    "X = df.drop(['id','target'],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "col_name = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "PCA(copy=True, iterated_power='auto', n_components=0.85, random_state=None,\n",
       "  svd_solver='auto', tol=0.0, whiten=False)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pca = PCA(0.85)\n",
    "pca.fit(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_pca = pca.transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 6.83548409e-01, -1.45650733e+00,  1.41194439e+00,\n",
       "        -2.68056064e+00, -1.61344326e+00, -3.98978596e+00,\n",
       "        -2.83297985e+00, -2.91875887e+00, -2.51092737e+00,\n",
       "        -7.60788658e-01,  3.40090914e+00,  3.47573862e+00,\n",
       "        -2.88735251e+00, -2.81981778e+00,  3.99742237e+00,\n",
       "        -3.12120811e+00,  3.94496431e+00, -2.30208613e+00,\n",
       "        -2.18242780e+00, -6.97089152e-01, -7.91301377e-02,\n",
       "        -1.70547583e-02,  2.08468417e+00, -8.29616439e-01,\n",
       "         3.63721362e-02,  1.21502813e+00, -7.41837732e-01,\n",
       "         1.38895694e-01, -1.18525553e+00,  6.55081669e-01,\n",
       "         5.99073265e-01,  3.95822800e-02, -8.29231896e-01,\n",
       "        -4.38844407e-01],\n",
       "       [-2.64598801e+00, -1.89324189e+00, -2.76867378e-01,\n",
       "         3.21335840e+00, -3.25637148e+00, -1.14531068e+00,\n",
       "        -1.99314038e+00, -2.44911130e-01,  7.78014413e-01,\n",
       "        -2.53829017e-02,  3.32310638e-01, -1.02879063e+00,\n",
       "        -9.21285374e-01, -1.66955130e+00, -5.84326750e-01,\n",
       "         1.48557274e-01, -1.18840681e+00,  1.96676994e+00,\n",
       "        -8.08464069e-01, -5.84619822e-01, -1.19666054e-01,\n",
       "         1.13319694e-01, -1.05774966e+00,  5.15433786e-03,\n",
       "        -4.25224257e-01, -5.83005546e-02, -2.46115675e-02,\n",
       "        -4.85665874e-01,  7.07659308e-02,  6.68971963e-01,\n",
       "         1.72220792e-01, -2.44037013e-01,  1.25888776e-01,\n",
       "         4.88528310e-02],\n",
       "       [-1.88129651e+00, -3.11140236e+00,  1.67102810e-01,\n",
       "        -3.58600540e-01, -2.23177796e+00, -2.00162498e+00,\n",
       "        -1.72460924e+00, -2.01780029e+00,  8.62700411e-02,\n",
       "         1.11106566e+00, -9.78311484e-01, -2.00161098e+00,\n",
       "        -1.61151278e+00, -1.08521172e+00,  3.88641979e-01,\n",
       "         8.18310484e-01, -1.51953991e-01,  1.62726618e+00,\n",
       "        -1.13504686e+00, -1.29628927e+00,  3.02870918e-01,\n",
       "         5.63173001e-01, -9.01551455e-01,  1.32667812e+00,\n",
       "         5.96037708e-01,  6.27894472e-01,  4.15949801e-02,\n",
       "        -5.13891627e-01, -2.82654765e-01,  1.18873808e+00,\n",
       "        -7.82889622e-02,  2.85086076e-01, -1.71933872e-01,\n",
       "        -4.46685275e-01],\n",
       "       [ 5.35425262e+00, -2.66828987e-01,  5.14006112e+00,\n",
       "        -2.75477193e+00, -1.60431516e+00, -3.89007933e-01,\n",
       "        -1.37981795e+00,  1.97366930e+00,  6.25097418e-01,\n",
       "         4.20155307e-01,  2.77772313e+00,  6.84510294e+00,\n",
       "        -1.64320135e+00,  4.64011623e+00, -3.73684965e+00,\n",
       "         2.05518502e+00, -3.19209700e+00, -5.11684242e+00,\n",
       "         3.35411981e+00, -3.12352637e-01,  6.87156860e+00,\n",
       "         5.33255755e+00, -9.50154553e+00,  2.28569519e+00,\n",
       "         1.61555758e+01,  1.79699230e+01, -4.58944316e+00,\n",
       "         2.15395841e+01,  2.80286348e+01,  4.31203637e-01,\n",
       "        -1.31786716e+01, -4.24576747e-01, -1.34874183e+00,\n",
       "         6.93063867e+00],\n",
       "       [-2.94844556e+00, -1.60110654e+00, -2.18033691e+00,\n",
       "         1.95982538e+00, -2.80821436e+00, -1.46710333e+00,\n",
       "        -2.48602074e+00, -5.99533958e-01, -2.54945309e-01,\n",
       "        -2.60541281e-01,  2.28531677e-01, -9.82072088e-01,\n",
       "        -1.17884025e+00, -1.02678104e+00, -1.56909085e+00,\n",
       "        -5.48553023e-03, -8.72053935e-01,  8.40324516e-01,\n",
       "         1.05685091e-01,  5.08271325e-01,  1.45024384e+00,\n",
       "         6.20836200e-01, -1.04717007e+00,  2.61690342e-01,\n",
       "         7.57924931e-01, -2.97166903e-01, -1.07264857e-01,\n",
       "        -9.01784972e-01, -7.01374135e-01,  1.44828048e+00,\n",
       "        -5.76267360e-01, -5.62842583e-01,  4.07442867e-01,\n",
       "        -1.17602436e+00],\n",
       "       [ 3.56782766e+00, -1.88833657e+00,  1.61014716e+00,\n",
       "        -3.57675126e+00, -1.54281127e-01, -3.05232591e+00,\n",
       "        -1.55883177e+00, -1.44100795e+00, -1.14137854e-01,\n",
       "        -6.48712080e-01,  2.18719716e+00,  2.78809117e+00,\n",
       "        -9.60313992e-01, -1.32111382e+00, -3.37354278e+00,\n",
       "         5.49635283e-02,  1.25018277e+00,  1.92420928e-02,\n",
       "        -1.27593698e+00, -3.43232042e-01, -1.02994138e+00,\n",
       "        -5.01040210e-01, -2.25567094e-01, -6.71903443e-01,\n",
       "        -8.11864280e-02,  1.88082923e+00, -2.07905089e-01,\n",
       "         2.81489698e-02, -3.36712587e-01,  2.09059662e+00,\n",
       "        -3.84320261e-01,  2.70457258e-02, -9.92796806e-01,\n",
       "         6.65206131e-01],\n",
       "       [-3.13237294e+00, -2.22116286e+00, -8.02301189e-01,\n",
       "         7.38911218e-01, -2.71967371e+00, -6.44889687e-01,\n",
       "        -1.74230574e+00,  1.74475210e-02, -1.54166864e+00,\n",
       "        -5.36322496e-01,  5.34996720e-01, -1.18111435e+00,\n",
       "        -1.38909838e+00, -1.97149461e+00, -1.73443084e+00,\n",
       "        -8.66225946e-01, -7.97420175e-01,  4.42300464e-01,\n",
       "         2.33660540e-01,  3.38912905e-01, -2.07402300e-02,\n",
       "        -4.45904601e-01, -8.34321344e-02, -1.17330654e+00,\n",
       "         3.77591686e-01,  2.33575247e-01,  2.20785460e-01,\n",
       "         8.12993603e-01, -2.01250656e-01,  1.24252321e+00,\n",
       "        -4.99862872e-01, -5.21927771e-01, -1.90781561e-01,\n",
       "        -7.61087612e-01],\n",
       "       [-4.09099944e+00, -1.11861953e+00, -1.82215154e+00,\n",
       "         2.07795608e+00, -2.63243983e+00, -1.37152141e+00,\n",
       "        -1.57151211e+00, -8.14004954e-01, -3.19295952e-01,\n",
       "        -2.11071483e-01, -1.61077474e-02, -9.19486699e-01,\n",
       "        -1.30362672e+00, -1.21949073e+00, -7.95852795e-01,\n",
       "         1.81938843e-01, -4.76473400e-01,  9.26610661e-01,\n",
       "        -2.08350294e-01, -6.72522902e-01,  7.63632715e-01,\n",
       "         1.18216031e-01, -1.61017669e+00,  1.23239638e-01,\n",
       "         1.60305093e-01, -5.71941176e-01,  2.92802739e-01,\n",
       "        -3.87498368e-01,  5.00070520e-01,  4.28821296e-01,\n",
       "         3.48978972e-01, -1.36940985e-01,  6.78303830e-01,\n",
       "         1.96752714e-01],\n",
       "       [ 2.50507285e+00, -2.28163702e+00,  1.05916680e+00,\n",
       "        -2.75061352e+00, -5.70367217e-01, -3.38922609e+00,\n",
       "        -1.55873344e+00, -1.32436449e+00, -2.40931450e-01,\n",
       "         3.90943806e-01,  2.32959930e-01,  1.54489821e+00,\n",
       "         2.12887507e-01, -3.13506019e-01, -1.18397113e+00,\n",
       "        -6.18138549e-01, -4.77425272e-01, -7.04581937e-02,\n",
       "         7.34427102e-01,  2.89498112e+00,  2.05114247e+00,\n",
       "        -2.58026850e+00, -1.46515963e+00, -5.75293496e-01,\n",
       "         1.56816909e+00, -1.25012168e-01,  1.77777013e+00,\n",
       "        -7.74838604e-01, -2.16538191e+00,  2.25129288e+00,\n",
       "         1.89295758e+00, -7.88058351e-01, -7.46561805e-01,\n",
       "         1.66132575e+00],\n",
       "       [-1.44394887e+00, -1.68644358e+00, -1.31017926e+00,\n",
       "         8.21103365e-01, -2.62605649e+00, -1.46781110e+00,\n",
       "        -2.05880677e+00,  1.26208220e+00, -5.66598571e-01,\n",
       "        -3.74910070e-01, -3.21847665e-01,  3.12200864e-01,\n",
       "        -1.01656262e+00, -8.46234603e-01, -1.49687826e+00,\n",
       "         8.05765565e-01, -4.88193779e-01,  8.80635432e-01,\n",
       "         8.74357093e-02, -3.51033682e-01,  1.54413883e+00,\n",
       "         7.03647197e-01, -1.03378323e+00,  6.06692795e-01,\n",
       "        -2.52681265e-02, -1.24237717e+00, -5.53489492e-01,\n",
       "        -6.03719744e-01,  5.12500414e-02,  1.22962399e+00,\n",
       "         3.94422263e-01, -1.23885256e+00,  2.63507096e-01,\n",
       "         6.77025488e-01]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_pca[:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "查看每个主成分的分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(34,)"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pca.explained_variance_.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 34 artists>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAADtJJREFUeJzt3W+sZHV9x/H3pwtUgzZI90I34OZis1FJU4HcEhoaY8FYWhqhCRhNazYNzbaNGk3b1NUnalMTbFL/PGhstqJuExU2qF0ixkpWiO0T9CKroqtF6Ra3bHevLUTtAw3y7YM5Wy+be3fO3DtzZ+a371eymXPOnJn55IT9zI/fnHM2VYUkqR0/N+0AkqTxstglqTEWuyQ1xmKXpMZY7JLUGItdkhpjsUtSYyx2SWqMxS5JjTlnKz9s+/bttbi4uJUfKUlz76GHHvp+VS303X9Li31xcZHl5eWt/EhJmntJ/mOU/Z2KkaTGWOyS1BiLXZIaY7FLUmMsdklqjMUuSY2x2CWpMRa7JDXGYpekxmzplaebsbj33nWfO3r7jVuYRJJmmyN2SWqMxS5JjbHYJakxFrskNaZXsSe5IMndSb6V5EiSX09yYZL7kjzaPb5g0mElScP1HbF/APhcVb0EeBlwBNgLHKqqXcChbl2SNGVDiz3JLwAvB+4AqKqfVNVTwE3A/m63/cDNkwopSeqvz4j9RcAK8JEkDyf5UJLzgYur6jhA93jRBHNKknrqU+znAFcBH6yqK4H/ZYRplyR7kiwnWV5ZWdlgTElSX32K/RhwrKoe7NbvZl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eMHuskv8rgx9FtDAawB6rqr7q/j3cymNJ4GPiDbiQ8dWfI/AVggcFU9GHgT1b9yLr2e81bsUuSzmzepmIkSUNY7JLUGItdkhpjsUtSYyx2SWqMxS5JjbHYJakxFrskNeb/AKdd9yGBhyBSAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(pca.explained_variance_)),pca.explained_variance_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1. 观察Otto商品的特征进行PCA各维的方差，可以得到什么结论？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由上图可以看出一下几点：\n",
    "- 原数据有93维特征，进行pca后只有34维，而我们设置的主成分比例为0.85，也就是这34维特征包含了原来93维特征85%的信息，对数据进行了压缩\n",
    "- 前4维主要的成分占了大多数的信息，在这些维度上的变换后的特征更有区分度"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 对Otto商品tfidf特征，进行PCA降维，给出各维方差的分布图。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/mac/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject\n",
      "  return f(*args, **kwds)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>feat_1_tfidf</th>\n",
       "      <th>feat_2_tfidf</th>\n",
       "      <th>feat_3_tfidf</th>\n",
       "      <th>feat_4_tfidf</th>\n",
       "      <th>feat_5_tfidf</th>\n",
       "      <th>feat_6_tfidf</th>\n",
       "      <th>feat_7_tfidf</th>\n",
       "      <th>feat_8_tfidf</th>\n",
       "      <th>feat_9_tfidf</th>\n",
       "      <th>feat_10_tfidf</th>\n",
       "      <th>...</th>\n",
       "      <th>feat_84_tfidf</th>\n",
       "      <th>feat_85_tfidf</th>\n",
       "      <th>feat_86_tfidf</th>\n",
       "      <th>feat_87_tfidf</th>\n",
       "      <th>feat_88_tfidf</th>\n",
       "      <th>feat_89_tfidf</th>\n",
       "      <th>feat_90_tfidf</th>\n",
       "      <th>feat_91_tfidf</th>\n",
       "      <th>feat_92_tfidf</th>\n",
       "      <th>feat_93_tfidf</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.080436</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.074055</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.227278</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.196169</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.011846</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.010756</td>\n",
       "      <td>0.103045</td>\n",
       "      <td>0.021145</td>\n",
       "      <td>0.073024</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.013132</td>\n",
       "      <td>...</td>\n",
       "      <td>0.446712</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.008051</td>\n",
       "      <td>0.022456</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.121616</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.142568</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 93 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   feat_1_tfidf  feat_2_tfidf  feat_3_tfidf  feat_4_tfidf  feat_5_tfidf  \\\n",
       "0      0.080436           0.0           0.0      0.000000      0.000000   \n",
       "1      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "2      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "3      0.011846           0.0           0.0      0.010756      0.103045   \n",
       "4      0.000000           0.0           0.0      0.000000      0.000000   \n",
       "\n",
       "   feat_6_tfidf  feat_7_tfidf  feat_8_tfidf  feat_9_tfidf  feat_10_tfidf  ...  \\\n",
       "0      0.000000      0.000000      0.000000           0.0       0.000000  ...   \n",
       "1      0.000000      0.000000      0.227278           0.0       0.000000  ...   \n",
       "2      0.000000      0.000000      0.196169           0.0       0.000000  ...   \n",
       "3      0.021145      0.073024      0.000000           0.0       0.013132  ...   \n",
       "4      0.000000      0.000000      0.000000           0.0       0.000000  ...   \n",
       "\n",
       "   feat_84_tfidf  feat_85_tfidf  feat_86_tfidf  feat_87_tfidf  feat_88_tfidf  \\\n",
       "0       0.000000       0.074055       0.000000       0.000000            0.0   \n",
       "1       0.000000       0.000000       0.000000       0.000000            0.0   \n",
       "2       0.000000       0.000000       0.000000       0.000000            0.0   \n",
       "3       0.446712       0.000000       0.008051       0.022456            0.0   \n",
       "4       0.000000       0.121616       0.000000       0.000000            0.0   \n",
       "\n",
       "   feat_89_tfidf  feat_90_tfidf  feat_91_tfidf  feat_92_tfidf  feat_93_tfidf  \n",
       "0            0.0       0.000000            0.0            0.0            0.0  \n",
       "1            0.0       0.000000            0.0            0.0            0.0  \n",
       "2            0.0       0.000000            0.0            0.0            0.0  \n",
       "3            0.0       0.000000            0.0            0.0            0.0  \n",
       "4            0.0       0.142568            0.0            0.0            0.0  \n",
       "\n",
       "[5 rows x 93 columns]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import TfidfTransformer\n",
    "tfidf = TfidfTransformer()\n",
    "X_tfidf = pd.DataFrame(columns=X.columns+\"_tfidf\",data=tfidf.fit_transform(X).toarray())\n",
    "X_tfidf.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "pca = PCA(n_components=0.85)\n",
    "pca.fit(X_tfidf)\n",
    "X_tfidf_pca = pca.transform(X_tfidf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 45 artists>"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAD/ZJREFUeJzt3X+s3Xddx/Hny5ZtCHGDrRpcW1uyaigBUUshEZVsOjpBSuKWdPijJjPVhBmMEOx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SpZXkzcB7q+pt09wXUxn6kqTxpnF6R5J0Coa+JDXE0Jekhhj6ktQQQ1+SGmLoS1JDDH1JaoihL0kN+X8PyN4h0IyEFQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(pca.explained_variance_ratio_)),pca.explained_variance_ratio_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "45"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(pca.explained_variance_ratio_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "跟原始数据比较，这里的主成分需要45个特征才能达到原数据的85%的信息"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 采用train_test_split，从将数据集中随机抽取10000条记录。对这部分数据进行PCA降维，保留85%的能量。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "# 将原始数据和tfidf数据拼接\n",
    "X = pd.concat([X,X_tfidf],axis=1)\n",
    "# 进行pca降维\n",
    "pca = PCA(0.85)\n",
    "X_pca = pca.fit_transform(X)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 34 artists>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwO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+ztrkkeRbwrKq6J8nXAXcDLwdezYSe6xPU/Aom9Fx3TyI4o6oeT/I04J+BnwdeC7yvqvYk+X3gQ1X1tnHWetwJan4N8JdVdWuf46zWkX+fR1JoEarqHxnc0TVs+PEeNzP4Bz8x5qh5olXVp6vqnm75v4AHGPw6fmLP9Qlqnlg18Hi3+rTuTwE/yOBRNTB553mumhdktYb/qfpYiQL+Jsnd3a+eTxXfWFWfhkEAAN8w5nr62pHkvm5aaGKmT0Z1T8n9LuAuTpFzPVIzTPC5TrImyb3AI8AHgI8Dn+seVQMTmB+jNVfV8fP8pu48X5/k9BMdY7WGf2ZpOxXmt763qp7H4AmqP9tNV+jkeBvwLcDFwKeB3xlvObNL8rXAe4FfqKrPj7uePmapeaLPdVV9qaouZvAEgk3Ad8zWbWWrOrHRmpM8B3g98O3A84FnAiecDlyt4d/rsRKTpqoOd38/AryfU+cJqJ/p5nuPz/s+MuZ65lVVn+n+AT0F/CETeK67+dz3An9SVe/rmif6XM9W86lwrgGq6nPA3wMvAM7K4FE1MMH5MVTz5m7ararqi8Dbmec8r9bw7/NIiomS5IzuSzKSnAFcAnzkxHtNjOHHe1wJ/MUYa+nleIB2fpQJO9fdl3o3Ag9U1ZuHNk3suZ6r5kk+10nWJTmrW/5q4IcYfFfxdwweVQOTd55nq/nfhwYFYfAdxQnP86q82wegu53sLXz5kRTj+pVxL0m+mcFoHwa/vH73JNac5E+BFzF4iuBngDcAfw7cAlwAfBLYWlUT8wXrHDW/iME0RAGHgJ85Ppc+CZJ8H/BPwIeBp7rmX2Uwhz6R5/oENV/BhJ7rJM9l8IXuGgaD4Vuqalf373EPg+mTDwI/3o2ox+4ENd8BrGMw7X0v8JqhL4a/8jirNfwlSXNbrdM+kqQTMPwlqUGGvyQ1yPCXpAYZ/pLUIMNfkhpk+EtSgwx/SWrQ/wIjCd9P6zgspAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(range(len(pca.explained_variance_ratio_)),pca.explained_variance_ratio_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 对3中得到的数据（对降维后的数据），训练RBF核SVM，并对超参数（C和gamma）进行超参数调优。结果和用原始数据的情况比较（SVM部分作业结果）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.svm import SVC\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "X_pca,_,y_pca,_ = train_test_split(X_pca,y,train_size = 10000/len(y),stratify=y)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((10000, 34), (10000,))"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X_pca.shape,y_pca.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "25546    Class_3\n",
       "1188     Class_1\n",
       "45104    Class_6\n",
       "32838    Class_6\n",
       "29434    Class_5\n",
       "Name: target, dtype: object"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fitting 5 folds for each of 64 candidates, totalling 320 fits\n",
      "[CV] C=0.0001, gamma=0.0001 ..........................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Using backend SequentialBackend with 1 concurrent workers.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV]  C=0.0001, gamma=0.0001, score=0.26010983524712933, total=   4.9s\n",
      "[CV] C=0.0001, gamma=0.0001 ..........................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Done   1 out of   1 | elapsed:    7.8s remaining:    0.0s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV]  C=0.0001, gamma=0.0001, score=0.26023976023976025, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.0001 ..........................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Done   2 out of   2 | elapsed:   15.2s remaining:    0.0s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV]  C=0.0001, gamma=0.0001, score=0.26036981509245377, total=   4.9s\n",
      "[CV] C=0.0001, gamma=0.0001 ..........................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Done   3 out of   3 | elapsed:   23.1s remaining:    0.0s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV]  C=0.0001, gamma=0.0001, score=0.26076076076076077, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.0001 ..........................................\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Done   4 out of   4 | elapsed:   30.5s remaining:    0.0s\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV]  C=0.0001, gamma=0.0001, score=0.26102204408817636, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.001 ...........................................\n",
      "[CV] . C=0.0001, gamma=0.001, score=0.26010983524712933, total=   4.6s\n",
      "[CV] C=0.0001, gamma=0.001 ...........................................\n",
      "[CV] . C=0.0001, gamma=0.001, score=0.26023976023976025, total=   4.6s\n",
      "[CV] C=0.0001, gamma=0.001 ...........................................\n",
      "[CV] . C=0.0001, gamma=0.001, score=0.26036981509245377, total=   4.6s\n",
      "[CV] C=0.0001, gamma=0.001 ...........................................\n",
      "[CV] . C=0.0001, gamma=0.001, score=0.26076076076076077, total=   4.6s\n",
      "[CV] C=0.0001, gamma=0.001 ...........................................\n",
      "[CV] . C=0.0001, gamma=0.001, score=0.26102204408817636, total=   4.6s\n",
      "[CV] C=0.0001, gamma=0.01 ............................................\n",
      "[CV] .. C=0.0001, gamma=0.01, score=0.26010983524712933, total=   4.7s\n",
      "[CV] C=0.0001, gamma=0.01 ............................................\n",
      "[CV] .. C=0.0001, gamma=0.01, score=0.26023976023976025, total=   4.7s\n",
      "[CV] C=0.0001, gamma=0.01 ............................................\n",
      "[CV] .. C=0.0001, gamma=0.01, score=0.26036981509245377, total=   4.7s\n",
      "[CV] C=0.0001, gamma=0.01 ............................................\n",
      "[CV] .. C=0.0001, gamma=0.01, score=0.26076076076076077, total=   4.7s\n",
      "[CV] C=0.0001, gamma=0.01 ............................................\n",
      "[CV] .. C=0.0001, gamma=0.01, score=0.26102204408817636, total=   4.7s\n",
      "[CV] C=0.0001, gamma=0.1 .............................................\n",
      "[CV] ... C=0.0001, gamma=0.1, score=0.26010983524712933, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.1 .............................................\n",
      "[CV] ... C=0.0001, gamma=0.1, score=0.26023976023976025, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.1 .............................................\n",
      "[CV] ... C=0.0001, gamma=0.1, score=0.26036981509245377, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.1 .............................................\n",
      "[CV] ... C=0.0001, gamma=0.1, score=0.26076076076076077, total=   4.5s\n",
      "[CV] C=0.0001, gamma=0.1 .............................................\n",
      "[CV] ... C=0.0001, gamma=0.1, score=0.26102204408817636, total=   4.5s\n",
      "[CV] C=0.0001, gamma=1 ...............................................\n",
      "[CV] ..... C=0.0001, gamma=1, score=0.26010983524712933, total=   4.8s\n",
      "[CV] C=0.0001, gamma=1 ...............................................\n",
      "[CV] ..... C=0.0001, gamma=1, score=0.26023976023976025, total=   4.9s\n",
      "[CV] C=0.0001, gamma=1 ...............................................\n",
      "[CV] ..... C=0.0001, gamma=1, score=0.26036981509245377, total=   4.8s\n",
      "[CV] C=0.0001, gamma=1 ...............................................\n",
      "[CV] ..... C=0.0001, gamma=1, score=0.26076076076076077, total=   4.8s\n",
      "[CV] C=0.0001, gamma=1 ...............................................\n",
      "[CV] ..... C=0.0001, gamma=1, score=0.26102204408817636, total=   4.8s\n",
      "[CV] C=0.0001, gamma=10 ..............................................\n",
      "[CV] .... C=0.0001, gamma=10, score=0.26010983524712933, total=   3.8s\n",
      "[CV] C=0.0001, gamma=10 ..............................................\n",
      "[CV] .... C=0.0001, gamma=10, score=0.26023976023976025, total=   3.8s\n",
      "[CV] C=0.0001, gamma=10 ..............................................\n",
      "[CV] .... C=0.0001, gamma=10, score=0.26036981509245377, total=   3.8s\n",
      "[CV] C=0.0001, gamma=10 ..............................................\n",
      "[CV] .... C=0.0001, gamma=10, score=0.26076076076076077, total=   3.8s\n",
      "[CV] C=0.0001, gamma=10 ..............................................\n",
      "[CV] .... C=0.0001, gamma=10, score=0.26102204408817636, total=   3.8s\n",
      "[CV] C=0.0001, gamma=100 .............................................\n",
      "[CV] ... C=0.0001, gamma=100, score=0.26010983524712933, total=   3.4s\n",
      "[CV] C=0.0001, gamma=100 .............................................\n",
      "[CV] ... C=0.0001, gamma=100, score=0.26023976023976025, total=   3.5s\n",
      "[CV] C=0.0001, gamma=100 .............................................\n",
      "[CV] ... C=0.0001, gamma=100, score=0.26036981509245377, total=   3.4s\n",
      "[CV] C=0.0001, gamma=100 .............................................\n",
      "[CV] ... C=0.0001, gamma=100, score=0.26076076076076077, total=   3.4s\n",
      "[CV] C=0.0001, gamma=100 .............................................\n",
      "[CV] ... C=0.0001, gamma=100, score=0.26102204408817636, total=   3.4s\n",
      "[CV] C=0.0001, gamma=1000 ............................................\n",
      "[CV] .. C=0.0001, gamma=1000, score=0.26010983524712933, total=   3.4s\n",
      "[CV] C=0.0001, gamma=1000 ............................................\n",
      "[CV] .. C=0.0001, gamma=1000, score=0.26023976023976025, total=   3.4s\n",
      "[CV] C=0.0001, gamma=1000 ............................................\n",
      "[CV] .. C=0.0001, gamma=1000, score=0.26036981509245377, total=   3.4s\n",
      "[CV] C=0.0001, gamma=1000 ............................................\n",
      "[CV] .. C=0.0001, gamma=1000, score=0.26076076076076077, total=   3.4s\n",
      "[CV] C=0.0001, gamma=1000 ............................................\n",
      "[CV] .. C=0.0001, gamma=1000, score=0.26102204408817636, total=   3.4s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] . C=0.001, gamma=0.0001, score=0.26010983524712933, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] . C=0.001, gamma=0.0001, score=0.26023976023976025, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] . C=0.001, gamma=0.0001, score=0.26036981509245377, total=   4.5s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] . C=0.001, gamma=0.0001, score=0.26076076076076077, total=   4.5s\n",
      "[CV] C=0.001, gamma=0.0001 ...........................................\n",
      "[CV] . C=0.001, gamma=0.0001, score=0.26102204408817636, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.001, score=0.26010983524712933, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.001, score=0.26023976023976025, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.001, score=0.26036981509245377, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.001, score=0.26076076076076077, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.001 ............................................\n",
      "[CV] .. C=0.001, gamma=0.001, score=0.26102204408817636, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.01, score=0.26010983524712933, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.01, score=0.26023976023976025, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.01, score=0.26036981509245377, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.01, score=0.26076076076076077, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.01 .............................................\n",
      "[CV] ... C=0.001, gamma=0.01, score=0.26102204408817636, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.1, score=0.26010983524712933, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.1, score=0.26023976023976025, total=   4.7s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.1, score=0.26036981509245377, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.1, score=0.26076076076076077, total=   4.6s\n",
      "[CV] C=0.001, gamma=0.1 ..............................................\n",
      "[CV] .... C=0.001, gamma=0.1, score=0.26102204408817636, total=   4.6s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ...... C=0.001, gamma=1, score=0.26010983524712933, total=   5.3s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ...... C=0.001, gamma=1, score=0.26023976023976025, total=   5.3s\n",
      "[CV] C=0.001, gamma=1 ................................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ...... C=0.001, gamma=1, score=0.26036981509245377, total=   5.3s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ...... C=0.001, gamma=1, score=0.26076076076076077, total=   5.3s\n",
      "[CV] C=0.001, gamma=1 ................................................\n",
      "[CV] ...... C=0.001, gamma=1, score=0.26102204408817636, total=   5.3s\n",
      "[CV] C=0.001, gamma=10 ...............................................\n",
      "[CV] ..... C=0.001, gamma=10, score=0.26010983524712933, total=   4.9s\n",
      "[CV] C=0.001, gamma=10 ...............................................\n",
      "[CV] ..... C=0.001, gamma=10, score=0.26023976023976025, total=   4.9s\n",
      "[CV] C=0.001, gamma=10 ...............................................\n",
      "[CV] ..... C=0.001, gamma=10, score=0.26036981509245377, total=   4.9s\n",
      "[CV] C=0.001, gamma=10 ...............................................\n",
      "[CV] ..... C=0.001, gamma=10, score=0.26076076076076077, total=   4.9s\n",
      "[CV] C=0.001, gamma=10 ...............................................\n",
      "[CV] ..... C=0.001, gamma=10, score=0.26102204408817636, total=   4.9s\n",
      "[CV] C=0.001, gamma=100 ..............................................\n",
      "[CV] .... C=0.001, gamma=100, score=0.26010983524712933, total=   4.4s\n",
      "[CV] C=0.001, gamma=100 ..............................................\n",
      "[CV] .... C=0.001, gamma=100, score=0.26023976023976025, total=   4.5s\n",
      "[CV] C=0.001, gamma=100 ..............................................\n",
      "[CV] .... C=0.001, gamma=100, score=0.26036981509245377, total=   4.4s\n",
      "[CV] C=0.001, gamma=100 ..............................................\n",
      "[CV] .... C=0.001, gamma=100, score=0.26076076076076077, total=   4.4s\n",
      "[CV] C=0.001, gamma=100 ..............................................\n",
      "[CV] .... C=0.001, gamma=100, score=0.26102204408817636, total=   4.4s\n",
      "[CV] C=0.001, gamma=1000 .............................................\n",
      "[CV] ... C=0.001, gamma=1000, score=0.26010983524712933, total=   4.4s\n",
      "[CV] C=0.001, gamma=1000 .............................................\n",
      "[CV] ... C=0.001, gamma=1000, score=0.26023976023976025, total=   4.4s\n",
      "[CV] C=0.001, gamma=1000 .............................................\n",
      "[CV] ... C=0.001, gamma=1000, score=0.26036981509245377, total=   4.4s\n",
      "[CV] C=0.001, gamma=1000 .............................................\n",
      "[CV] ... C=0.001, gamma=1000, score=0.26076076076076077, total=   4.4s\n",
      "[CV] C=0.001, gamma=1000 .............................................\n",
      "[CV] ... C=0.001, gamma=1000, score=0.26102204408817636, total=   4.4s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] ... C=0.01, gamma=0.0001, score=0.2775836245631553, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] .. C=0.01, gamma=0.0001, score=0.27972027972027974, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] .... C=0.01, gamma=0.0001, score=0.280359820089955, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] .. C=0.01, gamma=0.0001, score=0.27927927927927926, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.0001 ............................................\n",
      "[CV] .... C=0.01, gamma=0.0001, score=0.281563126252505, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.5322016974538193, total=   4.3s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.5114885114885115, total=   4.3s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.5247376311844077, total=   4.4s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.5280280280280281, total=   4.3s\n",
      "[CV] C=0.01, gamma=0.001 .............................................\n",
      "[CV] .... C=0.01, gamma=0.001, score=0.5215430861723447, total=   4.4s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] .... C=0.01, gamma=0.01, score=0.49425861208187716, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] .... C=0.01, gamma=0.01, score=0.49100899100899104, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.4897551224387806, total=   4.5s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.4904904904904905, total=   4.5s\n",
      "[CV] C=0.01, gamma=0.01 ..............................................\n",
      "[CV] ..... C=0.01, gamma=0.01, score=0.4909819639278557, total=   4.6s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.1, score=0.26010983524712933, total=   6.5s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.1, score=0.26023976023976025, total=   6.5s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.1, score=0.26036981509245377, total=   6.4s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.1, score=0.26076076076076077, total=   6.4s\n",
      "[CV] C=0.01, gamma=0.1 ...............................................\n",
      "[CV] ..... C=0.01, gamma=0.1, score=0.26102204408817636, total=   6.4s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ....... C=0.01, gamma=1, score=0.26010983524712933, total=   8.0s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ....... C=0.01, gamma=1, score=0.26023976023976025, total=   8.0s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ....... C=0.01, gamma=1, score=0.26036981509245377, total=   8.1s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ....... C=0.01, gamma=1, score=0.26076076076076077, total=   8.0s\n",
      "[CV] C=0.01, gamma=1 .................................................\n",
      "[CV] ....... C=0.01, gamma=1, score=0.26102204408817636, total=   8.1s\n",
      "[CV] C=0.01, gamma=10 ................................................\n",
      "[CV] ...... C=0.01, gamma=10, score=0.26010983524712933, total=   6.6s\n",
      "[CV] C=0.01, gamma=10 ................................................\n",
      "[CV] ...... C=0.01, gamma=10, score=0.26023976023976025, total=   6.6s\n",
      "[CV] C=0.01, gamma=10 ................................................\n",
      "[CV] ...... C=0.01, gamma=10, score=0.26036981509245377, total=   6.6s\n",
      "[CV] C=0.01, gamma=10 ................................................\n",
      "[CV] ...... C=0.01, gamma=10, score=0.26076076076076077, total=   6.6s\n",
      "[CV] C=0.01, gamma=10 ................................................\n",
      "[CV] ...... C=0.01, gamma=10, score=0.26102204408817636, total=   6.6s\n",
      "[CV] C=0.01, gamma=100 ...............................................\n",
      "[CV] ..... C=0.01, gamma=100, score=0.26010983524712933, total=   5.8s\n",
      "[CV] C=0.01, gamma=100 ...............................................\n",
      "[CV] ..... C=0.01, gamma=100, score=0.26023976023976025, total=   5.8s\n",
      "[CV] C=0.01, gamma=100 ...............................................\n",
      "[CV] ..... C=0.01, gamma=100, score=0.26036981509245377, total=   5.8s\n",
      "[CV] C=0.01, gamma=100 ...............................................\n",
      "[CV] ..... C=0.01, gamma=100, score=0.26076076076076077, total=   5.8s\n",
      "[CV] C=0.01, gamma=100 ...............................................\n",
      "[CV] ..... C=0.01, gamma=100, score=0.26102204408817636, total=   5.8s\n",
      "[CV] C=0.01, gamma=1000 ..............................................\n",
      "[CV] .... C=0.01, gamma=1000, score=0.26010983524712933, total=   5.8s\n",
      "[CV] C=0.01, gamma=1000 ..............................................\n",
      "[CV] .... C=0.01, gamma=1000, score=0.26023976023976025, total=   5.7s\n",
      "[CV] C=0.01, gamma=1000 ..............................................\n",
      "[CV] .... C=0.01, gamma=1000, score=0.26036981509245377, total=   5.8s\n",
      "[CV] C=0.01, gamma=1000 ..............................................\n",
      "[CV] .... C=0.01, gamma=1000, score=0.26076076076076077, total=   5.7s\n",
      "[CV] C=0.01, gamma=1000 ..............................................\n",
      "[CV] .... C=0.01, gamma=1000, score=0.26102204408817636, total=   5.9s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ..... C=0.1, gamma=0.0001, score=0.564153769345981, total=   4.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.5439560439560439, total=   3.9s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.5592203898050975, total=   4.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.5580580580580581, total=   4.0s\n",
      "[CV] C=0.1, gamma=0.0001 .............................................\n",
      "[CV] .... C=0.1, gamma=0.0001, score=0.5511022044088176, total=   3.9s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6884672990514229, total=   2.8s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6728271728271729, total=   2.8s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6901549225387307, total=   2.8s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6751751751751752, total=   2.8s\n",
      "[CV] C=0.1, gamma=0.001 ..............................................\n",
      "[CV] ..... C=0.1, gamma=0.001, score=0.6863727454909819, total=   2.8s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6764852720918622, total=   3.4s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6548451548451548, total=   3.3s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6611694152923538, total=   3.3s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6741741741741741, total=   3.3s\n",
      "[CV] C=0.1, gamma=0.01 ...............................................\n",
      "[CV] ...... C=0.1, gamma=0.01, score=0.6718436873747495, total=   3.3s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.3929106340489266, total=   6.8s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.3881118881118881, total=   6.8s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.3698150924537731, total=   6.8s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ....... C=0.1, gamma=0.1, score=0.3768768768768769, total=   6.8s\n",
      "[CV] C=0.1, gamma=0.1 ................................................\n",
      "[CV] ...... C=0.1, gamma=0.1, score=0.37675350701402804, total=   6.8s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ........ C=0.1, gamma=1, score=0.26010983524712933, total=   8.4s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ........ C=0.1, gamma=1, score=0.26023976023976025, total=   8.4s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ........ C=0.1, gamma=1, score=0.26036981509245377, total=   8.4s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ........ C=0.1, gamma=1, score=0.26076076076076077, total=   8.4s\n",
      "[CV] C=0.1, gamma=1 ..................................................\n",
      "[CV] ........ C=0.1, gamma=1, score=0.26102204408817636, total=   8.4s\n",
      "[CV] C=0.1, gamma=10 .................................................\n",
      "[CV] ....... C=0.1, gamma=10, score=0.26010983524712933, total=   7.0s\n",
      "[CV] C=0.1, gamma=10 .................................................\n",
      "[CV] ....... C=0.1, gamma=10, score=0.26023976023976025, total=   7.0s\n",
      "[CV] C=0.1, gamma=10 .................................................\n",
      "[CV] ....... C=0.1, gamma=10, score=0.26036981509245377, total=   7.0s\n",
      "[CV] C=0.1, gamma=10 .................................................\n",
      "[CV] ....... C=0.1, gamma=10, score=0.26076076076076077, total=   6.9s\n",
      "[CV] C=0.1, gamma=10 .................................................\n",
      "[CV] ....... C=0.1, gamma=10, score=0.26102204408817636, total=   6.9s\n",
      "[CV] C=0.1, gamma=100 ................................................\n",
      "[CV] ...... C=0.1, gamma=100, score=0.26010983524712933, total=   6.2s\n",
      "[CV] C=0.1, gamma=100 ................................................\n",
      "[CV] ...... C=0.1, gamma=100, score=0.26023976023976025, total=   6.1s\n",
      "[CV] C=0.1, gamma=100 ................................................\n",
      "[CV] ...... C=0.1, gamma=100, score=0.26036981509245377, total=   6.1s\n",
      "[CV] C=0.1, gamma=100 ................................................\n",
      "[CV] ...... C=0.1, gamma=100, score=0.26076076076076077, total=   6.1s\n",
      "[CV] C=0.1, gamma=100 ................................................\n",
      "[CV] ...... C=0.1, gamma=100, score=0.26102204408817636, total=   6.1s\n",
      "[CV] C=0.1, gamma=1000 ...............................................\n",
      "[CV] ..... C=0.1, gamma=1000, score=0.26010983524712933, total=   6.1s\n",
      "[CV] C=0.1, gamma=1000 ...............................................\n",
      "[CV] ..... C=0.1, gamma=1000, score=0.26023976023976025, total=   6.1s\n",
      "[CV] C=0.1, gamma=1000 ...............................................\n",
      "[CV] ..... C=0.1, gamma=1000, score=0.26036981509245377, total=   6.1s\n",
      "[CV] C=0.1, gamma=1000 ...............................................\n",
      "[CV] ..... C=0.1, gamma=1000, score=0.26076076076076077, total=   6.1s\n",
      "[CV] C=0.1, gamma=1000 ...............................................\n",
      "[CV] ..... C=0.1, gamma=1000, score=0.26102204408817636, total=   6.2s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6969545681477783, total=   2.7s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6748251748251748, total=   2.6s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6956521739130435, total=   2.6s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6801801801801802, total=   2.6s\n",
      "[CV] C=1, gamma=0.0001 ...............................................\n",
      "[CV] ...... C=1, gamma=0.0001, score=0.6938877755511023, total=   2.6s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.7373939091362955, total=   2.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.7242757242757243, total=   2.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.7296351824087957, total=   2.0s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.7317317317317318, total=   1.9s\n",
      "[CV] C=1, gamma=0.001 ................................................\n",
      "[CV] ....... C=1, gamma=0.001, score=0.7274549098196392, total=   2.0s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ......... C=1, gamma=0.01, score=0.745381927109336, total=   2.8s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7417582417582418, total=   2.8s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7411294352823589, total=   2.8s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7342342342342343, total=   2.7s\n",
      "[CV] C=1, gamma=0.01 .................................................\n",
      "[CV] ........ C=1, gamma=0.01, score=0.7329659318637275, total=   2.8s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.5551672491263105, total=   7.5s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.5624375624375625, total=   7.5s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.5422288855572214, total=   7.5s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ......... C=1, gamma=0.1, score=0.5355355355355356, total=   7.5s\n",
      "[CV] C=1, gamma=0.1 ..................................................\n",
      "[CV] ......... C=1, gamma=0.1, score=0.5445891783567134, total=   7.5s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] ........... C=1, gamma=1, score=0.2710933599600599, total=   8.8s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] .......... C=1, gamma=1, score=0.27672327672327673, total=   8.8s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] ........... C=1, gamma=1, score=0.2818590704647676, total=   8.8s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] .......... C=1, gamma=1, score=0.27927927927927926, total=   8.8s\n",
      "[CV] C=1, gamma=1 ....................................................\n",
      "[CV] .......... C=1, gamma=1, score=0.28306613226452904, total=   8.8s\n",
      "[CV] C=1, gamma=10 ...................................................\n",
      "[CV] ......... C=1, gamma=10, score=0.26110833749375933, total=   7.4s\n",
      "[CV] C=1, gamma=10 ...................................................\n",
      "[CV] ......... C=1, gamma=10, score=0.26223776223776224, total=   7.4s\n",
      "[CV] C=1, gamma=10 ...................................................\n",
      "[CV] .......... C=1, gamma=10, score=0.2613693153423288, total=   7.4s\n",
      "[CV] C=1, gamma=10 ...................................................\n",
      "[CV] ......... C=1, gamma=10, score=0.26226226226226224, total=   7.4s\n",
      "[CV] C=1, gamma=10 ...................................................\n",
      "[CV] ......... C=1, gamma=10, score=0.26152304609218435, total=   7.4s\n",
      "[CV] C=1, gamma=100 ..................................................\n",
      "[CV] ........ C=1, gamma=100, score=0.26010983524712933, total=   6.5s\n",
      "[CV] C=1, gamma=100 ..................................................\n",
      "[CV] ........ C=1, gamma=100, score=0.26023976023976025, total=   6.5s\n",
      "[CV] C=1, gamma=100 ..................................................\n",
      "[CV] ........ C=1, gamma=100, score=0.26036981509245377, total=   6.5s\n",
      "[CV] C=1, gamma=100 ..................................................\n",
      "[CV] ........ C=1, gamma=100, score=0.26076076076076077, total=   6.5s\n",
      "[CV] C=1, gamma=100 ..................................................\n",
      "[CV] ........ C=1, gamma=100, score=0.26102204408817636, total=   6.5s\n",
      "[CV] C=1, gamma=1000 .................................................\n",
      "[CV] ....... C=1, gamma=1000, score=0.26010983524712933, total=   6.5s\n",
      "[CV] C=1, gamma=1000 .................................................\n",
      "[CV] ....... C=1, gamma=1000, score=0.26023976023976025, total=   6.5s\n",
      "[CV] C=1, gamma=1000 .................................................\n",
      "[CV] ....... C=1, gamma=1000, score=0.26036981509245377, total=   6.5s\n",
      "[CV] C=1, gamma=1000 .................................................\n",
      "[CV] ....... C=1, gamma=1000, score=0.26076076076076077, total=   6.7s\n",
      "[CV] C=1, gamma=1000 .................................................\n",
      "[CV] ....... C=1, gamma=1000, score=0.26102204408817636, total=   6.5s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ...... C=10, gamma=0.0001, score=0.727408886669995, total=   1.9s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.7202797202797203, total=   1.9s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.7316341829085458, total=   1.9s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.7247247247247247, total=   1.9s\n",
      "[CV] C=10, gamma=0.0001 ..............................................\n",
      "[CV] ..... C=10, gamma=0.0001, score=0.7264529058116233, total=   1.9s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7563654518222666, total=   1.7s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7532467532467533, total=   1.7s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7501249375312344, total=   1.7s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ...... C=10, gamma=0.001, score=0.7482482482482482, total=   1.7s\n",
      "[CV] C=10, gamma=0.001 ...............................................\n",
      "[CV] ....... C=10, gamma=0.001, score=0.753006012024048, total=   1.7s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7493759360958562, total=   2.8s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7462537462537463, total=   2.8s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7401299350324838, total=   2.8s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7372372372372372, total=   2.8s\n",
      "[CV] C=10, gamma=0.01 ................................................\n",
      "[CV] ....... C=10, gamma=0.01, score=0.7454909819639278, total=   2.9s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.5731402895656516, total=   8.0s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ......... C=10, gamma=0.1, score=0.570929070929071, total=   8.0s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.5487256371814093, total=   8.0s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.5415415415415415, total=   8.0s\n",
      "[CV] C=10, gamma=0.1 .................................................\n",
      "[CV] ........ C=10, gamma=0.1, score=0.5551102204408818, total=   8.0s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.2770843734398402, total=   9.4s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] ......... C=10, gamma=1, score=0.28121878121878124, total=   9.4s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] ......... C=10, gamma=1, score=0.28285857071464265, total=   9.4s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.2822822822822823, total=   9.4s\n",
      "[CV] C=10, gamma=1 ...................................................\n",
      "[CV] .......... C=10, gamma=1, score=0.2875751503006012, total=   9.4s\n",
      "[CV] C=10, gamma=10 ..................................................\n",
      "[CV] ......... C=10, gamma=10, score=0.2616075886170744, total=   8.2s\n",
      "[CV] C=10, gamma=10 ..................................................\n",
      "[CV] ........ C=10, gamma=10, score=0.26223776223776224, total=   8.2s\n",
      "[CV] C=10, gamma=10 ..................................................\n",
      "[CV] ........ C=10, gamma=10, score=0.26186906546726635, total=   8.1s\n",
      "[CV] C=10, gamma=10 ..................................................\n",
      "[CV] ........ C=10, gamma=10, score=0.26226226226226224, total=   8.1s\n",
      "[CV] C=10, gamma=10 ..................................................\n",
      "[CV] ........ C=10, gamma=10, score=0.26152304609218435, total=   8.1s\n",
      "[CV] C=10, gamma=100 .................................................\n",
      "[CV] ....... C=10, gamma=100, score=0.26010983524712933, total=   7.3s\n",
      "[CV] C=10, gamma=100 .................................................\n",
      "[CV] ....... C=10, gamma=100, score=0.26073926073926074, total=   7.3s\n",
      "[CV] C=10, gamma=100 .................................................\n",
      "[CV] ....... C=10, gamma=100, score=0.26036981509245377, total=   7.2s\n",
      "[CV] C=10, gamma=100 .................................................\n",
      "[CV] ....... C=10, gamma=100, score=0.26126126126126126, total=   7.2s\n",
      "[CV] C=10, gamma=100 .................................................\n",
      "[CV] ....... C=10, gamma=100, score=0.26102204408817636, total=   7.2s\n",
      "[CV] C=10, gamma=1000 ................................................\n",
      "[CV] ...... C=10, gamma=1000, score=0.26010983524712933, total=   7.2s\n",
      "[CV] C=10, gamma=1000 ................................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ...... C=10, gamma=1000, score=0.26023976023976025, total=   7.2s\n",
      "[CV] C=10, gamma=1000 ................................................\n",
      "[CV] ...... C=10, gamma=1000, score=0.26036981509245377, total=   7.1s\n",
      "[CV] C=10, gamma=1000 ................................................\n",
      "[CV] ...... C=10, gamma=1000, score=0.26076076076076077, total=   7.1s\n",
      "[CV] C=10, gamma=1000 ................................................\n",
      "[CV] ...... C=10, gamma=1000, score=0.26102204408817636, total=   7.2s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7478781827259111, total=   1.7s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7457542457542458, total=   1.7s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7436281859070465, total=   1.7s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7427427427427428, total=   1.7s\n",
      "[CV] C=100, gamma=0.0001 .............................................\n",
      "[CV] .... C=100, gamma=0.0001, score=0.7434869739478958, total=   1.8s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7653519720419371, total=   2.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7622377622377622, total=   2.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7421289355322339, total=   2.0s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7462462462462462, total=   1.9s\n",
      "[CV] C=100, gamma=0.001 ..............................................\n",
      "[CV] ..... C=100, gamma=0.001, score=0.7545090180360722, total=   1.9s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7338991512730904, total=   3.3s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7257742257742258, total=   3.3s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ....... C=100, gamma=0.01, score=0.728135932033983, total=   3.3s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ...... C=100, gamma=0.01, score=0.7072072072072072, total=   3.3s\n",
      "[CV] C=100, gamma=0.01 ...............................................\n",
      "[CV] ....... C=100, gamma=0.01, score=0.719939879759519, total=   3.4s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.5716425361957065, total=   8.0s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ........ C=100, gamma=0.1, score=0.567932067932068, total=   8.0s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ........ C=100, gamma=0.1, score=0.543728135932034, total=   8.0s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.5395395395395396, total=   8.0s\n",
      "[CV] C=100, gamma=0.1 ................................................\n",
      "[CV] ....... C=100, gamma=0.1, score=0.5516032064128257, total=   8.0s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.2770843734398402, total=   9.4s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ........ C=100, gamma=1, score=0.28121878121878124, total=   9.4s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ........ C=100, gamma=1, score=0.28285857071464265, total=   9.4s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.2822822822822823, total=   9.4s\n",
      "[CV] C=100, gamma=1 ..................................................\n",
      "[CV] ......... C=100, gamma=1, score=0.2875751503006012, total=   9.4s\n",
      "[CV] C=100, gamma=10 .................................................\n",
      "[CV] ........ C=100, gamma=10, score=0.2616075886170744, total=   8.1s\n",
      "[CV] C=100, gamma=10 .................................................\n",
      "[CV] ....... C=100, gamma=10, score=0.26223776223776224, total=   8.1s\n",
      "[CV] C=100, gamma=10 .................................................\n",
      "[CV] ....... C=100, gamma=10, score=0.26186906546726635, total=   8.1s\n",
      "[CV] C=100, gamma=10 .................................................\n",
      "[CV] ....... C=100, gamma=10, score=0.26226226226226224, total=   8.1s\n",
      "[CV] C=100, gamma=10 .................................................\n",
      "[CV] ....... C=100, gamma=10, score=0.26152304609218435, total=   8.1s\n",
      "[CV] C=100, gamma=100 ................................................\n",
      "[CV] ...... C=100, gamma=100, score=0.26010983524712933, total=   7.2s\n",
      "[CV] C=100, gamma=100 ................................................\n",
      "[CV] ...... C=100, gamma=100, score=0.26073926073926074, total=   7.2s\n",
      "[CV] C=100, gamma=100 ................................................\n",
      "[CV] ...... C=100, gamma=100, score=0.26036981509245377, total=   7.2s\n",
      "[CV] C=100, gamma=100 ................................................\n",
      "[CV] ...... C=100, gamma=100, score=0.26126126126126126, total=   7.2s\n",
      "[CV] C=100, gamma=100 ................................................\n",
      "[CV] ...... C=100, gamma=100, score=0.26102204408817636, total=   7.2s\n",
      "[CV] C=100, gamma=1000 ...............................................\n",
      "[CV] ..... C=100, gamma=1000, score=0.26010983524712933, total=   7.1s\n",
      "[CV] C=100, gamma=1000 ...............................................\n",
      "[CV] ..... C=100, gamma=1000, score=0.26023976023976025, total=   7.1s\n",
      "[CV] C=100, gamma=1000 ...............................................\n",
      "[CV] ..... C=100, gamma=1000, score=0.26036981509245377, total=   7.1s\n",
      "[CV] C=100, gamma=1000 ...............................................\n",
      "[CV] ..... C=100, gamma=1000, score=0.26076076076076077, total=   7.0s\n",
      "[CV] C=100, gamma=1000 ...............................................\n",
      "[CV] ..... C=100, gamma=1000, score=0.26102204408817636, total=   7.1s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7518721917124314, total=   2.2s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7537462537462537, total=   2.2s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7546226886556722, total=   2.2s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7427427427427428, total=   2.2s\n",
      "[CV] C=1000, gamma=0.0001 ............................................\n",
      "[CV] ... C=1000, gamma=0.0001, score=0.7444889779559118, total=   2.2s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7433849226160759, total=   4.0s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7387612387612388, total=   3.7s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] ..... C=1000, gamma=0.001, score=0.728135932033983, total=   3.7s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7282282282282282, total=   3.7s\n",
      "[CV] C=1000, gamma=0.001 .............................................\n",
      "[CV] .... C=1000, gamma=0.001, score=0.7359719438877755, total=   3.6s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7199201198202696, total=   4.6s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7012987012987013, total=   4.6s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.7126436781609196, total=   4.5s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n",
      "[CV] ..... C=1000, gamma=0.01, score=0.6986986986986987, total=   4.6s\n",
      "[CV] C=1000, gamma=0.01 ..............................................\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[CV] ..... C=1000, gamma=0.01, score=0.7124248496993988, total=   4.5s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.5701447828257613, total=   7.9s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.5714285714285714, total=   7.9s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.5417291354322838, total=   7.9s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.5385385385385385, total=   7.9s\n",
      "[CV] C=1000, gamma=0.1 ...............................................\n",
      "[CV] ...... C=1000, gamma=0.1, score=0.5511022044088176, total=   8.0s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.2770843734398402, total=   9.3s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ....... C=1000, gamma=1, score=0.28121878121878124, total=   9.3s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ....... C=1000, gamma=1, score=0.28285857071464265, total=   9.3s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.2822822822822823, total=   9.2s\n",
      "[CV] C=1000, gamma=1 .................................................\n",
      "[CV] ........ C=1000, gamma=1, score=0.2875751503006012, total=   9.3s\n",
      "[CV] C=1000, gamma=10 ................................................\n",
      "[CV] ....... C=1000, gamma=10, score=0.2616075886170744, total=   8.1s\n",
      "[CV] C=1000, gamma=10 ................................................\n",
      "[CV] ...... C=1000, gamma=10, score=0.26223776223776224, total=   8.0s\n",
      "[CV] C=1000, gamma=10 ................................................\n",
      "[CV] ...... C=1000, gamma=10, score=0.26186906546726635, total=   8.0s\n",
      "[CV] C=1000, gamma=10 ................................................\n",
      "[CV] ...... C=1000, gamma=10, score=0.26226226226226224, total=   8.1s\n",
      "[CV] C=1000, gamma=10 ................................................\n",
      "[CV] ...... C=1000, gamma=10, score=0.26152304609218435, total=   8.0s\n",
      "[CV] C=1000, gamma=100 ...............................................\n",
      "[CV] ..... C=1000, gamma=100, score=0.26010983524712933, total=   7.1s\n",
      "[CV] C=1000, gamma=100 ...............................................\n",
      "[CV] ..... C=1000, gamma=100, score=0.26073926073926074, total=   7.1s\n",
      "[CV] C=1000, gamma=100 ...............................................\n",
      "[CV] ..... C=1000, gamma=100, score=0.26036981509245377, total=   7.1s\n",
      "[CV] C=1000, gamma=100 ...............................................\n",
      "[CV] ..... C=1000, gamma=100, score=0.26126126126126126, total=   7.1s\n",
      "[CV] C=1000, gamma=100 ...............................................\n",
      "[CV] ..... C=1000, gamma=100, score=0.26102204408817636, total=   7.1s\n",
      "[CV] C=1000, gamma=1000 ..............................................\n",
      "[CV] .... C=1000, gamma=1000, score=0.26010983524712933, total=   7.1s\n",
      "[CV] C=1000, gamma=1000 ..............................................\n",
      "[CV] .... C=1000, gamma=1000, score=0.26023976023976025, total=   7.1s\n",
      "[CV] C=1000, gamma=1000 ..............................................\n",
      "[CV] .... C=1000, gamma=1000, score=0.26036981509245377, total=   7.1s\n",
      "[CV] C=1000, gamma=1000 ..............................................\n",
      "[CV] .... C=1000, gamma=1000, score=0.26076076076076077, total=   7.1s\n",
      "[CV] C=1000, gamma=1000 ..............................................\n",
      "[CV] .... C=1000, gamma=1000, score=0.26102204408817636, total=   7.1s\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "[Parallel(n_jobs=1)]: Done 320 out of 320 | elapsed: 42.4min finished\n"
     ]
    }
   ],
   "source": [
    "svc = SVC(kernel='rbf')\n",
    "tuned_params = dict(C=[1e-4,1e-3,1e-2,1e-1,1,10,100,1000],gamma=[1e-4,1e-3,1e-2,1e-1,1,10,100,1000])\n",
    "gc = GridSearchCV(svc,tuned_params,cv=5,verbose=5,return_train_score=True)\n",
    "gc_result = gc.fit(X_pca,y_pca)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'C': 100, 'gamma': 0.001} 0.7541\n"
     ]
    }
   ],
   "source": [
    "print(gc_result.best_params_,gc_result.best_score_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'mean_fit_time': array([3.94512606, 3.87054305, 3.95663257, 3.78243141, 3.9976366 ,\n",
      "       3.1951448 , 2.85486941, 2.82248039, 3.84283643, 3.93239255,\n",
      "       3.95757322, 3.90745106, 4.43876605, 4.27225037, 3.85408936,\n",
      "       3.83611574, 3.8884131 , 3.68512955, 3.89534831, 5.7357358 ,\n",
      "       7.16910672, 5.93745255, 5.18940988, 5.20515819, 3.32417836,\n",
      "       2.32584357, 2.77319603, 6.10264454, 7.51813297, 6.30201182,\n",
      "       5.54293799, 5.52647777, 2.14645023, 1.54561057, 2.29133744,\n",
      "       6.83487453, 7.91950235, 6.729286  , 5.90569344, 5.94729176,\n",
      "       1.48523879, 1.32120881, 2.35766826, 7.29078202, 8.51551676,\n",
      "       7.47498798, 6.65918245, 6.58040366, 1.35525379, 1.58643737,\n",
      "       2.8542531 , 7.33120632, 8.50285807, 7.46948123, 6.61175961,\n",
      "       6.51386728, 1.84295325, 3.4110992 , 4.10342865, 7.25050592,\n",
      "       8.3960783 , 7.38165884, 6.52633328, 6.51208806]), 'std_fit_time': array([0.17686695, 0.01294621, 0.00481606, 0.01258438, 0.01659907,\n",
      "       0.0043175 , 0.0457346 , 0.00833745, 0.00975084, 0.02616935,\n",
      "       0.00693992, 0.0214023 , 0.00325588, 0.00526971, 0.01725182,\n",
      "       0.00962917, 0.00440871, 0.03735035, 0.00908568, 0.02989684,\n",
      "       0.0217094 , 0.01033861, 0.00600331, 0.0513718 , 0.01726377,\n",
      "       0.01087515, 0.04492974, 0.00971306, 0.0153068 , 0.01171374,\n",
      "       0.02072782, 0.02966654, 0.01795944, 0.01207085, 0.00909261,\n",
      "       0.01998934, 0.02858485, 0.00681662, 0.0153536 , 0.07204143,\n",
      "       0.00833879, 0.01716279, 0.02312893, 0.01804434, 0.01351441,\n",
      "       0.02778984, 0.0500337 , 0.0228181 , 0.01918791, 0.03784345,\n",
      "       0.02995204, 0.02320866, 0.02237256, 0.01860653, 0.01920277,\n",
      "       0.0228713 , 0.02068565, 0.14644465, 0.04924039, 0.02503026,\n",
      "       0.02315238, 0.02567556, 0.01403914, 0.02074642]), 'mean_score_time': array([0.72756038, 0.71065717, 0.70505228, 0.71435828, 0.83503728,\n",
      "       0.62725768, 0.56251583, 0.55928388, 0.71025925, 0.7093257 ,\n",
      "       0.70290732, 0.71377039, 0.83980012, 0.64150896, 0.57905116,\n",
      "       0.57758665, 0.70978541, 0.66169567, 0.65785527, 0.719662  ,\n",
      "       0.88419085, 0.65718617, 0.57875724, 0.59399261, 0.62559314,\n",
      "       0.49737763, 0.52533431, 0.70175657, 0.87962494, 0.65565896,\n",
      "       0.57857742, 0.57661386, 0.47738605, 0.41479182, 0.46617045,\n",
      "       0.66762648, 0.86830511, 0.65656629, 0.57777553, 0.58208609,\n",
      "       0.4044703 , 0.38236337, 0.47333665, 0.67979221, 0.88242784,\n",
      "       0.66182156, 0.59143729, 0.58483996, 0.3746366 , 0.36990938,\n",
      "       0.46559682, 0.67961178, 0.87730231, 0.66197162, 0.58504124,\n",
      "       0.57570624, 0.34953918, 0.36002035, 0.44444814, 0.67001328,\n",
      "       0.86922612, 0.65676064, 0.57716732, 0.5764308 ]), 'std_score_time': array([0.01727911, 0.00351679, 0.00191482, 0.00461865, 0.00271687,\n",
      "       0.00168602, 0.00667728, 0.00123928, 0.00201258, 0.00267054,\n",
      "       0.00089005, 0.00241451, 0.00132499, 0.00120292, 0.0018916 ,\n",
      "       0.00113489, 0.0006152 , 0.0034142 , 0.00822262, 0.00486429,\n",
      "       0.00106168, 0.00129675, 0.00044484, 0.02572175, 0.01550223,\n",
      "       0.00263015, 0.00210045, 0.01137327, 0.00507016, 0.00095075,\n",
      "       0.00122557, 0.00101922, 0.00315148, 0.004693  , 0.00227202,\n",
      "       0.00224208, 0.00255229, 0.00426235, 0.00103126, 0.00615346,\n",
      "       0.00362636, 0.00121681, 0.00170819, 0.00187084, 0.01176444,\n",
      "       0.00059187, 0.00563513, 0.00185891, 0.00840127, 0.00289897,\n",
      "       0.00300599, 0.00217174, 0.00108526, 0.00126893, 0.00130319,\n",
      "       0.0003095 , 0.00265897, 0.00252296, 0.00365328, 0.00206312,\n",
      "       0.00676276, 0.00767302, 0.00149085, 0.00139631]), 'param_C': masked_array(data=[0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001,\n",
      "                   0.0001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001,\n",
      "                   0.001, 0.001, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,\n",
      "                   0.01, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 1, 1, 1,\n",
      "                   1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 100,\n",
      "                   100, 100, 100, 100, 100, 100, 100, 1000, 1000, 1000,\n",
      "                   1000, 1000, 1000, 1000, 1000],\n",
      "             mask=[False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False],\n",
      "       fill_value='?',\n",
      "            dtype=object), 'param_gamma': masked_array(data=[0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 0.0001,\n",
      "                   0.001, 0.01, 0.1, 1, 10, 100, 1000, 0.0001, 0.001,\n",
      "                   0.01, 0.1, 1, 10, 100, 1000, 0.0001, 0.001, 0.01, 0.1,\n",
      "                   1, 10, 100, 1000, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100,\n",
      "                   1000, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000,\n",
      "                   0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 0.0001,\n",
      "                   0.001, 0.01, 0.1, 1, 10, 100, 1000],\n",
      "             mask=[False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False,\n",
      "                   False, False, False, False, False, False, False, False],\n",
      "       fill_value='?',\n",
      "            dtype=object), 'params': [{'C': 0.0001, 'gamma': 0.0001}, {'C': 0.0001, 'gamma': 0.001}, {'C': 0.0001, 'gamma': 0.01}, {'C': 0.0001, 'gamma': 0.1}, {'C': 0.0001, 'gamma': 1}, {'C': 0.0001, 'gamma': 10}, {'C': 0.0001, 'gamma': 100}, {'C': 0.0001, 'gamma': 1000}, {'C': 0.001, 'gamma': 0.0001}, {'C': 0.001, 'gamma': 0.001}, {'C': 0.001, 'gamma': 0.01}, {'C': 0.001, 'gamma': 0.1}, {'C': 0.001, 'gamma': 1}, {'C': 0.001, 'gamma': 10}, {'C': 0.001, 'gamma': 100}, {'C': 0.001, 'gamma': 1000}, {'C': 0.01, 'gamma': 0.0001}, {'C': 0.01, 'gamma': 0.001}, {'C': 0.01, 'gamma': 0.01}, {'C': 0.01, 'gamma': 0.1}, {'C': 0.01, 'gamma': 1}, {'C': 0.01, 'gamma': 10}, {'C': 0.01, 'gamma': 100}, {'C': 0.01, 'gamma': 1000}, {'C': 0.1, 'gamma': 0.0001}, {'C': 0.1, 'gamma': 0.001}, {'C': 0.1, 'gamma': 0.01}, {'C': 0.1, 'gamma': 0.1}, {'C': 0.1, 'gamma': 1}, {'C': 0.1, 'gamma': 10}, {'C': 0.1, 'gamma': 100}, {'C': 0.1, 'gamma': 1000}, {'C': 1, 'gamma': 0.0001}, {'C': 1, 'gamma': 0.001}, {'C': 1, 'gamma': 0.01}, {'C': 1, 'gamma': 0.1}, {'C': 1, 'gamma': 1}, {'C': 1, 'gamma': 10}, {'C': 1, 'gamma': 100}, {'C': 1, 'gamma': 1000}, {'C': 10, 'gamma': 0.0001}, {'C': 10, 'gamma': 0.001}, {'C': 10, 'gamma': 0.01}, {'C': 10, 'gamma': 0.1}, {'C': 10, 'gamma': 1}, {'C': 10, 'gamma': 10}, {'C': 10, 'gamma': 100}, {'C': 10, 'gamma': 1000}, {'C': 100, 'gamma': 0.0001}, {'C': 100, 'gamma': 0.001}, {'C': 100, 'gamma': 0.01}, {'C': 100, 'gamma': 0.1}, {'C': 100, 'gamma': 1}, {'C': 100, 'gamma': 10}, {'C': 100, 'gamma': 100}, {'C': 100, 'gamma': 1000}, {'C': 1000, 'gamma': 0.0001}, {'C': 1000, 'gamma': 0.001}, {'C': 1000, 'gamma': 0.01}, {'C': 1000, 'gamma': 0.1}, {'C': 1000, 'gamma': 1}, {'C': 1000, 'gamma': 10}, {'C': 1000, 'gamma': 100}, {'C': 1000, 'gamma': 1000}], 'split0_test_score': array([0.26010984, 0.26010984, 0.26010984, 0.26010984, 0.26010984,\n",
      "       0.26010984, 0.26010984, 0.26010984, 0.26010984, 0.26010984,\n",
      "       0.26010984, 0.26010984, 0.26010984, 0.26010984, 0.26010984,\n",
      "       0.26010984, 0.27758362, 0.5322017 , 0.49425861, 0.26010984,\n",
      "       0.26010984, 0.26010984, 0.26010984, 0.26010984, 0.56415377,\n",
      "       0.6884673 , 0.67648527, 0.39291063, 0.26010984, 0.26010984,\n",
      "       0.26010984, 0.26010984, 0.69695457, 0.73739391, 0.74538193,\n",
      "       0.55516725, 0.27109336, 0.26110834, 0.26010984, 0.26010984,\n",
      "       0.72740889, 0.75636545, 0.74937594, 0.57314029, 0.27708437,\n",
      "       0.26160759, 0.26010984, 0.26010984, 0.74787818, 0.76535197,\n",
      "       0.73389915, 0.57164254, 0.27708437, 0.26160759, 0.26010984,\n",
      "       0.26010984, 0.75187219, 0.74338492, 0.71992012, 0.57014478,\n",
      "       0.27708437, 0.26160759, 0.26010984, 0.26010984]), 'split1_test_score': array([0.26023976, 0.26023976, 0.26023976, 0.26023976, 0.26023976,\n",
      "       0.26023976, 0.26023976, 0.26023976, 0.26023976, 0.26023976,\n",
      "       0.26023976, 0.26023976, 0.26023976, 0.26023976, 0.26023976,\n",
      "       0.26023976, 0.27972028, 0.51148851, 0.49100899, 0.26023976,\n",
      "       0.26023976, 0.26023976, 0.26023976, 0.26023976, 0.54395604,\n",
      "       0.67282717, 0.65484515, 0.38811189, 0.26023976, 0.26023976,\n",
      "       0.26023976, 0.26023976, 0.67482517, 0.72427572, 0.74175824,\n",
      "       0.56243756, 0.27672328, 0.26223776, 0.26023976, 0.26023976,\n",
      "       0.72027972, 0.75324675, 0.74625375, 0.57092907, 0.28121878,\n",
      "       0.26223776, 0.26073926, 0.26023976, 0.74575425, 0.76223776,\n",
      "       0.72577423, 0.56793207, 0.28121878, 0.26223776, 0.26073926,\n",
      "       0.26023976, 0.75374625, 0.73876124, 0.7012987 , 0.57142857,\n",
      "       0.28121878, 0.26223776, 0.26073926, 0.26023976]), 'split2_test_score': array([0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.28035982, 0.52473763, 0.48975512, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.55922039,\n",
      "       0.69015492, 0.66116942, 0.36981509, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.69565217, 0.72963518, 0.74112944,\n",
      "       0.54222889, 0.28185907, 0.26136932, 0.26036982, 0.26036982,\n",
      "       0.73163418, 0.75012494, 0.74012994, 0.54872564, 0.28285857,\n",
      "       0.26186907, 0.26036982, 0.26036982, 0.74362819, 0.74212894,\n",
      "       0.72813593, 0.54372814, 0.28285857, 0.26186907, 0.26036982,\n",
      "       0.26036982, 0.75462269, 0.72813593, 0.71264368, 0.54172914,\n",
      "       0.28285857, 0.26186907, 0.26036982, 0.26036982]), 'split3_test_score': array([0.26076076, 0.26076076, 0.26076076, 0.26076076, 0.26076076,\n",
      "       0.26076076, 0.26076076, 0.26076076, 0.26076076, 0.26076076,\n",
      "       0.26076076, 0.26076076, 0.26076076, 0.26076076, 0.26076076,\n",
      "       0.26076076, 0.27927928, 0.52802803, 0.49049049, 0.26076076,\n",
      "       0.26076076, 0.26076076, 0.26076076, 0.26076076, 0.55805806,\n",
      "       0.67517518, 0.67417417, 0.37687688, 0.26076076, 0.26076076,\n",
      "       0.26076076, 0.26076076, 0.68018018, 0.73173173, 0.73423423,\n",
      "       0.53553554, 0.27927928, 0.26226226, 0.26076076, 0.26076076,\n",
      "       0.72472472, 0.74824825, 0.73723724, 0.54154154, 0.28228228,\n",
      "       0.26226226, 0.26126126, 0.26076076, 0.74274274, 0.74624625,\n",
      "       0.70720721, 0.53953954, 0.28228228, 0.26226226, 0.26126126,\n",
      "       0.26076076, 0.74274274, 0.72822823, 0.6986987 , 0.53853854,\n",
      "       0.28228228, 0.26226226, 0.26126126, 0.26076076]), 'split4_test_score': array([0.26102204, 0.26102204, 0.26102204, 0.26102204, 0.26102204,\n",
      "       0.26102204, 0.26102204, 0.26102204, 0.26102204, 0.26102204,\n",
      "       0.26102204, 0.26102204, 0.26102204, 0.26102204, 0.26102204,\n",
      "       0.26102204, 0.28156313, 0.52154309, 0.49098196, 0.26102204,\n",
      "       0.26102204, 0.26102204, 0.26102204, 0.26102204, 0.5511022 ,\n",
      "       0.68637275, 0.67184369, 0.37675351, 0.26102204, 0.26102204,\n",
      "       0.26102204, 0.26102204, 0.69388778, 0.72745491, 0.73296593,\n",
      "       0.54458918, 0.28306613, 0.26152305, 0.26102204, 0.26102204,\n",
      "       0.72645291, 0.75300601, 0.74549098, 0.55511022, 0.28757515,\n",
      "       0.26152305, 0.26102204, 0.26102204, 0.74348697, 0.75450902,\n",
      "       0.71993988, 0.55160321, 0.28757515, 0.26152305, 0.26102204,\n",
      "       0.26102204, 0.74448898, 0.73597194, 0.71242485, 0.5511022 ,\n",
      "       0.28757515, 0.26152305, 0.26102204, 0.26102204]), 'mean_test_score': array([0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605,\n",
      "       0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605,\n",
      "       0.2797, 0.5236, 0.4913, 0.2605, 0.2605, 0.2605, 0.2605, 0.2605,\n",
      "       0.5553, 0.6826, 0.6677, 0.3809, 0.2605, 0.2605, 0.2605, 0.2605,\n",
      "       0.6883, 0.7301, 0.7391, 0.548 , 0.2784, 0.2617, 0.2605, 0.2605,\n",
      "       0.7261, 0.7522, 0.7437, 0.5579, 0.2822, 0.2619, 0.2607, 0.2605,\n",
      "       0.7447, 0.7541, 0.723 , 0.5549, 0.2822, 0.2619, 0.2607, 0.2605,\n",
      "       0.7495, 0.7349, 0.709 , 0.5546, 0.2822, 0.2619, 0.2607, 0.2605]), 'std_test_score': array([0.00033974, 0.00033974, 0.00033974, 0.00033974, 0.00033974,\n",
      "       0.00033974, 0.00033974, 0.00033974, 0.00033974, 0.00033974,\n",
      "       0.00033974, 0.00033974, 0.00033974, 0.00033974, 0.00033974,\n",
      "       0.00033974, 0.00130865, 0.00701484, 0.00154885, 0.00033974,\n",
      "       0.00033974, 0.00033974, 0.00033974, 0.00033974, 0.00704107,\n",
      "       0.0071619 , 0.00829925, 0.0084    , 0.00033974, 0.00033974,\n",
      "       0.00033974, 0.00033974, 0.00903188, 0.00440671, 0.00473116,\n",
      "       0.00959415, 0.00426038, 0.0004683 , 0.00033974, 0.00033974,\n",
      "       0.00369544, 0.00279395, 0.00439252, 0.01234383, 0.00335999,\n",
      "       0.0003078 , 0.00041896, 0.00033974, 0.00188008, 0.0089247 ,\n",
      "       0.00907274, 0.01282315, 0.00335999, 0.0003078 , 0.00041896,\n",
      "       0.00033974, 0.00491151, 0.00597355, 0.00787143, 0.01386471,\n",
      "       0.00335999, 0.0003078 , 0.00041896, 0.00033974]), 'rank_test_score': array([35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 26,\n",
      "       20, 21, 35, 35, 35, 35, 35, 16, 13, 14, 22, 35, 35, 35, 35, 12,  8,\n",
      "        6, 19, 27, 31, 35, 35,  9,  2,  5, 15, 23, 28, 32, 35,  4,  1, 10,\n",
      "       17, 23, 28, 32, 35,  3,  7, 11, 18, 23, 28, 32, 35], dtype=int32), 'split0_train_score': array([0.26059772, 0.26059772, 0.26059772, 0.26059772, 0.26059772,\n",
      "       0.26059772, 0.26059772, 0.26059772, 0.26059772, 0.26059772,\n",
      "       0.26059772, 0.26059772, 0.26059772, 0.26059772, 0.26059772,\n",
      "       0.26059772, 0.27835438, 0.52257096, 0.49205952, 0.26059772,\n",
      "       0.26059772, 0.26059772, 0.26059772, 0.26059772, 0.55433287,\n",
      "       0.6840065 , 0.67862949, 0.39464799, 0.26084782, 0.26059772,\n",
      "       0.26059772, 0.26059772, 0.6901338 , 0.73815181, 0.80717769,\n",
      "       0.94122796, 0.99912467, 1.        , 1.        , 1.        ,\n",
      "       0.72902338, 0.78391897, 0.90033763, 0.99537326, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.76253595, 0.82643491,\n",
      "       0.96386145, 0.99974991, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.7906715 , 0.88595723, 0.98887083, 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'split1_train_score': array([0.26056514, 0.26056514, 0.26056514, 0.26056514, 0.26056514,\n",
      "       0.26056514, 0.26056514, 0.26056514, 0.26056514, 0.26056514,\n",
      "       0.26056514, 0.26056514, 0.26056514, 0.26056514, 0.26056514,\n",
      "       0.26056514, 0.28132033, 0.52975744, 0.49287322, 0.26056514,\n",
      "       0.26056514, 0.26056514, 0.26056514, 0.26056514, 0.55976494,\n",
      "       0.68629657, 0.67979495, 0.39309827, 0.26056514, 0.26056514,\n",
      "       0.26056514, 0.26056514, 0.69242311, 0.74106027, 0.8072018 ,\n",
      "       0.94061015, 0.99874969, 1.        , 1.        , 1.        ,\n",
      "       0.73293323, 0.78394599, 0.89822456, 0.99549887, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.76406602, 0.82495624,\n",
      "       0.96374094, 0.99974994, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.78994749, 0.88622156, 0.98987247, 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'split2_train_score': array([0.26053257, 0.26053257, 0.26053257, 0.26053257, 0.26053257,\n",
      "       0.26053257, 0.26053257, 0.26053257, 0.26053257, 0.26053257,\n",
      "       0.26053257, 0.26053257, 0.26053257, 0.26053257, 0.26053257,\n",
      "       0.26053257, 0.27965996, 0.52419052, 0.49231154, 0.26053257,\n",
      "       0.26053257, 0.26053257, 0.26053257, 0.26053257, 0.55469434,\n",
      "       0.68383548, 0.68233529, 0.39167396, 0.26053257, 0.26053257,\n",
      "       0.26053257, 0.26053257, 0.68908614, 0.73984248, 0.80735092,\n",
      "       0.94224278, 0.99849981, 1.        , 1.        , 1.        ,\n",
      "       0.73134142, 0.78459807, 0.89873734, 0.99537442, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.76084511, 0.82685336,\n",
      "       0.96137017, 0.99974997, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.79097387, 0.88361045, 0.9896237 , 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'split3_train_score': array([0.26043489, 0.26043489, 0.26043489, 0.26043489, 0.26043489,\n",
      "       0.26043489, 0.26043489, 0.26043489, 0.26043489, 0.26043489,\n",
      "       0.26043489, 0.26043489, 0.26043489, 0.26043489, 0.26043489,\n",
      "       0.26043489, 0.27893027, 0.52324419, 0.49075231, 0.26043489,\n",
      "       0.26043489, 0.26043489, 0.26043489, 0.26043489, 0.55523619,\n",
      "       0.68807798, 0.6812047 , 0.39790052, 0.26043489, 0.26043489,\n",
      "       0.26043489, 0.26043489, 0.69057736, 0.73769058, 0.80729818,\n",
      "       0.9460135 , 0.99887528, 1.        , 1.        , 1.        ,\n",
      "       0.7291927 , 0.78692827, 0.90302424, 0.99637591, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.76505874, 0.8304174 ,\n",
      "       0.96375906, 0.99987503, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.79205199, 0.88902774, 0.99162709, 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'split4_train_score': array([0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.26036982,\n",
      "       0.26036982, 0.2806097 , 0.52361319, 0.49212894, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.26036982, 0.26036982, 0.55584708,\n",
      "       0.68403298, 0.68028486, 0.39092954, 0.26049475, 0.26036982,\n",
      "       0.26036982, 0.26036982, 0.6884058 , 0.7410045 , 0.81234383,\n",
      "       0.94115442, 0.99875062, 1.        , 1.        , 1.        ,\n",
      "       0.73450775, 0.78785607, 0.89955022, 0.99462769, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.76661669, 0.83233383,\n",
      "       0.96189405, 0.99962519, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.79397801, 0.88993003, 0.98838081, 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'mean_train_score': array([0.26050003, 0.26050003, 0.26050003, 0.26050003, 0.26050003,\n",
      "       0.26050003, 0.26050003, 0.26050003, 0.26050003, 0.26050003,\n",
      "       0.26050003, 0.26050003, 0.26050003, 0.26050003, 0.26050003,\n",
      "       0.26050003, 0.27977493, 0.52467526, 0.49202511, 0.26050003,\n",
      "       0.26050003, 0.26050003, 0.26050003, 0.26050003, 0.55597508,\n",
      "       0.6852499 , 0.68044986, 0.39365006, 0.26057503, 0.26050003,\n",
      "       0.26050003, 0.26050003, 0.69012524, 0.73954993, 0.80827448,\n",
      "       0.94224976, 0.99880002, 1.        , 1.        , 1.        ,\n",
      "       0.7313997 , 0.78544947, 0.8999748 , 0.99545003, 1.        ,\n",
      "       1.        , 1.        , 1.        , 0.7638245 , 0.82819915,\n",
      "       0.96292513, 0.99975001, 1.        , 1.        , 1.        ,\n",
      "       1.        , 0.79152457, 0.8869494 , 0.98967498, 1.        ,\n",
      "       1.        , 1.        , 1.        , 1.        ]), 'std_train_score': array([8.49013893e-05, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       8.49013893e-05, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       8.49013893e-05, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       8.49013893e-05, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       1.07978904e-03, 2.59489989e-03, 6.97611372e-04, 8.49013893e-05,\n",
      "       8.49013893e-05, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       1.96278023e-03, 1.68054008e-03, 1.25654534e-03, 2.47681320e-03,\n",
      "       1.43106606e-04, 8.49013893e-05, 8.49013893e-05, 8.49013893e-05,\n",
      "       1.37991960e-03, 1.40672708e-03, 2.03564809e-03, 1.95437522e-03,\n",
      "       2.03057050e-04, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
      "       2.12286560e-03, 1.63133959e-03, 1.68556643e-03, 5.56325639e-04,\n",
      "       0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
      "       1.99575302e-03, 2.73701958e-03, 1.06945648e-03, 7.90076054e-05,\n",
      "       0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,\n",
      "       1.40112287e-03, 2.27448563e-03, 1.11120806e-03, 0.00000000e+00,\n",
      "       0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00])}\n"
     ]
    }
   ],
   "source": [
    "print(gc_result.cv_results_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "mean_train_score = gc_result.cv_results_['mean_train_score']\n",
    "mean_test_score = gc_result.cv_results_['mean_test_score']"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "svm作业中的结果为：     \n",
    "\n",
    "最佳训练效果得分： 0.7684\n",
    "\n",
    "最佳超参数 {'C': 10, 'gamma': 0.001}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这里的结果稍微差一点，但差距并不大，已经比不用核的svm好了。\n",
    "\n",
    "由于特征维度只有原来的1/3，所以训练速度快了许多"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
